package com.digitalchina.lxnsy.activity.farmTrain;

import android.app.Activity;
import android.content.Intent;
import android.webkit.JavascriptInterface;

import com.digitalchina.lxnsy.base.BaseHtmlActivity;

/**
 * ================================================
 * 项目名称：android
 * 类描述：我的培训需求列表
 * 创建人：yzm
 * 创建时间：2020/1/8 17:26
 * 修改备注：
 * ================================================
 */
public class MyDemandListActivity extends BaseHtmlActivity {

    @Override
    protected void loadHtml() {
        webView.addJavascriptObject(new JsApi(), null);
        loadUrl("train-my-training");
        setTitle("我的培训需求");
        setRightText("发布需求");
    }

    @Override
    public void rightOnClick() {
        callJsMethod("add");
        go(SendTrainNeedActivity.class);
    }

    public class JsApi {
        //选择合作机构
        @JavascriptInterface
        public void selectAgency(Object msg) {
            startActivityForResult(new Intent(activity, TrainSelectAgencyActivity.class), 1);
        }

        //需求详情
        @JavascriptInterface
        public void goDetail(Object msg) {
            go(DemandDetailActivity.class,"msg","2");
        }

        //查看合作机构
        @JavascriptInterface
        public void seeAgency(Object msg) {
            go(TrainSelectFinshActivity.class);
        }


        //修改培训需求
        @JavascriptInterface
        public void goEdit(Object msg) {
            go(SendTrainNeedActivity.class);
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode== Activity.RESULT_OK){
            callJsMethod("refresh");
        }
    }
}
